﻿using System;
using System.Collections.Generic;
#if DEBUG
using System.Diagnostics;
#endif // #if DEBUG
using System.Linq;
using System.Text;

using FRLUser = FRL.DebtChased.Repository.User;

namespace FRL.DebtChased.Repository.ViewModels
{

	/// <summary>
	/// Declaration of DevMessageViewModel class
	/// </summary>
	public class DevMessageViewModel
	{

		/////////////////////////////////////////////////////////
		// Nested classes

		public class Element
		{

			/////////////////////////////////////////////////////////
			// Attributes

			private int m_iDevMessageId;
			public int DevMessageId
			{
				get { return m_iDevMessageId; }
			}

			public string UserAsText { get; set; }
			public string Page { get; set; }

			public string Description { get; set; }
			public string PriortyAsText { get; set; }
			public string CategoryAsText { get; set; }
			public DateTime Date { get; set; }

			/////////////////////////////////////////////////////////////
			// Construction

			public Element(int iDevMessageId)
			{

				// Initialize member variables
				m_iDevMessageId = iDevMessageId;

			}

		}

		/////////////////////////////////////////////////////////
		// Attributes

		private List<Element> m_elements = new List<Element>();
		public List<Element> Elements
		{
			get { return m_elements; }
		}

		/////////////////////////////////////////////////////////
		// Construction

		public DevMessageViewModel(DebtChasedEntities ent)
		{

			// TODO
			// This function needs updating
#if DEBUG
			Debug.Assert(false);
#endif // #if DEBUG

			/*
			// Load the development message
			var results = from dm in ent.DevMessages
						  join c in ent.Contacts on dm.UserId equals c.ParentId
						  where (c.fdContactType == (int)Definitions.eContactType.Staff)
						  orderby dm.Date
						  select new { 
								dm.DevMessageId,
								dm.Date,
								dm.Description,
								dm.fdCategory,
								dm.fdPriority,
								dm.Page,
								c.FirstName,
								c.Surname
						  };

			// Load the entities
			foreach (var ob in results)
			{

				// Add an entities
				this.Elements.Add(new Element(ob.DevMessageId) { 
					Date = ob.Date,
					CategoryAsText = ((DevMessage.eCategory)ob.fdCategory).ToString(),
					PriortyAsText = ((DevMessage.ePriority)ob.fdPriority).ToString(),
					Page = ob.Page,
					Description = ob.Description,
					UserAsText = Contact.ComposeFullName(ob.FirstName, ob.Surname)
				});

			}
			 */

		}

	}

}
